<?php
/**
 * 状态数组
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/12
 * Time: 17:06
 */


/**
 * 性别
 * @param null $key
 * @return array|string
 */
function sexArr($key = null)
{
    $arr = [
        0 => ['name'=>'未知', 'val'=>0],
        1 => ['name'=>'男', 'val'=>1],
        2 => ['name'=>'女', 'val'=>2],
    ];

    if (is_null($key)) {
        return $arr;
    }

    return $arr[$key]['name'] ?? '未定义';
}

/**
 * 工作状态
 * @param null $key
 * @return array|string
 */
function workingStatusArr($key = null)
{
    $arr = [
        1 => ['name'=>'在职', 'val'=>1],
        2 => ['name'=>'离职', 'val'=>2],
        3 => ['name'=>'休假', 'val'=>3],
    ];

    if (is_null($key)) {
        return $arr;
    }

    return $arr[$key]['name'] ?? '未定义';
}

/**
 * 在职类型
 * @param null $key
 * @return array|string
 */
function workingTypeArr($key = null)
{
    $arr = [
        1 => ['name'=>'正式员工', 'val'=>1],
        2 => ['name'=>'实习', 'val'=>2],
        3 => ['name'=>'兼职', 'val'=>3],
    ];

    if (is_null($key)) {
        return $arr;
    }

    return $arr[$key]['name'] ?? '未定义';
}

/**
 * 轮播图位置
 * @param null $key
 * @return array|string
 */
function loopImgPositionArr($key = null)
{
    $arr = [
        1 => ['name'=>'商城首页', 'val'=>1],
    ];

    if (is_null($key)) {
        return $arr;
    }

    return $arr[$key]['name'] ?? '未定义';
}

/**
 * 订单状态
 * @param null $key
 * @return array|string
 */
function orderStatusArr($key = null)
{
    $arr = [
        1 => ['name'=>'待付款', 'val'=>1],
        2 => ['name'=>'已取消', 'val'=>2],
        3 => ['name'=>'已付款', 'val'=>3],
        4 => ['name'=>'已发货', 'val'=>4],
        5 => ['name'=>'已收货', 'val'=>5],
        6 => ['name'=>'已评价', 'val'=>6],
        7 => ['name'=>'已关闭', 'val'=>7],
    ];

    if (is_null($key)) {
        return $arr;
    }

    return $arr[$key]['name'] ?? '未定义';
}

/**
 * 标签分类
 * @param null $key
 * @return array|string
 */
function tagTypeArr($key = null)
{
    $arr = [
        1 => ['name'=>'产品', 'val'=>1],
        2 => ['name'=>'订单', 'val'=>2],
        3 => ['name'=>'用户', 'val'=>3],
        4 => ['name'=>'员工', 'val'=>4],
        5 => ['name'=>'文章', 'val'=>5],
        6 => ['name'=>'问卷', 'val'=>6],
    ];

    if (is_null($key)) {
        return $arr;
    }

    return $arr[$key]['name'] ?? '未定义';
}

/**
 * 优惠券分类
 * @param null $key
 * @return array|string
 */
function couponTypeArr($key = null)
{
    $arr = [
        1 => ['name'=>'普通优惠券', 'val'=>1],
        2 => ['name'=>'注册赠券', 'val'=>2],
        3 => ['name'=>'邀请赠券', 'val'=>3],
    ];

    if (is_null($key)) {
        return $arr;
    }

    return $arr[$key]['name'] ?? '未定义';
}

/**
 * 优惠券适用范围
 * @param null $key
 * @return array|string
 */
function couponUseArr($key = null)
{
    $arr = [
        1 => ['name'=>'全场通用', 'val'=>1],
        2 => ['name'=>'指定分类', 'val'=>2],
        3 => ['name'=>'指定品牌', 'val'=>3],
    ];

    if (is_null($key)) {
        return $arr;
    }

    return $arr[$key]['name'] ?? '未定义';
}

/**
 * 优惠券适用范围
 * @param null $key
 * @return array|string
 */
function couponPlatformArr($key = null)
{
    $arr = [
        1 => ['name'=>'全平台', 'val'=>1],
        2 => ['name'=>'网页端', 'val'=>2],
        3 => ['name'=>'移动端', 'val'=>3],
    ];

    if (is_null($key)) {
        return $arr;
    }

    return $arr[$key]['name'] ?? '未定义';
}

/**
 * 计价单位
 * @param null $key
 * @return array|string
 */
function priceUnitArr($key = null)
{
    $arr = [
        1 => ['name'=>'件', 'val'=>'件'],
        2 => ['name'=>'台', 'val'=>'台'],
        3 => ['name'=>'个', 'val'=>'个'],
        4 => ['name'=>'本', 'val'=>'本'],
        5 => ['name'=>'只', 'val'=>'只'],
        6 => ['name'=>'盒', 'val'=>'盒'],
        7 => ['name'=>'箱', 'val'=>'箱'],
    ];

    if (is_null($key)) {
        return $arr;
    }

    return $arr[$key]['name'] ?? '未定义';
}

